<?php

include( "./admin/include/func.php");
include( "./admin/include/thumb.php");

$panels = array ();

$g_id  = isset( $_GET['sorszam']) ? (int) $_GET['sorszam'] : 0;
$g_kod = isset( $_GET['kod']) ? trim( strip_tags( $_GET['kod'])) : '';
      
$success = true;
$errors = array();

if ($g_id < 1) {
	$success = false;
	array_push($errors, "A Sorszám nincs megadva!");
}

if ($g_kod == '') {
	$success = false;
	array_push($errors, "Az Aktívkód nincs megadva!");
}

if ($success) {
	$db->sql = "SELECT email FROM hirdetes WHERE id='$g_id' AND aktivkod='$g_kod'";
	$db->query();	
	if (mysql_num_rows( $db->rs) < 1) {
		$success = false;
		array_push($errors, "Nincs ilyen hirdetés!");		
	} else {
		$rs = mysql_fetch_assoc( $db->rs);
		$g_email = $rs['email'];
	}
}
                 
if (! $success) {
	
	$panels = array ();
	
	$error_panel = array (
		'caption' => 'Hiba',
		'title'   => 'Sikertelen aktiválás!',
		'body'    => "<ul class='errors'>Hibás aktiváló adatok!</ul>",
		'height'  => 20
	);
	
	array_unshift( $panels, $error_panel);
	
} else {

		$db->sql = "UPDATE hirdetes SET aktiv='1',aktivedon=NOW(),lastmodified=NOW() WHERE id='$g_id' AND aktivkod='$g_kod'";
		$db->query();
		//print $db->sql;
		
		header ("Location: hirdetesek.php?sorszam=$g_id");
		exit();
}

?>

<?php include ("header.php"); ?>

<?php include ("top.php"); ?>

<?php include ("left.php"); ?>
							
<div id="middle">

<?php foreach( $panels as $panel) { ?>
	
	<div class="form-panel">		
		<div>
			<img src='./images1/x3a2.gif' width="21px" height="42px" class="fleft" alt='apróhirdetés' /> 
			<div class="hptop">
				<p class="hpcaption"><?php print $panel['caption']; ?></p>
				<p class="hptitle"><?php print $panel['title']; ?></p>
			</div>	
			<img src='./images1/x3b2.gif' width="21px" height="42px" class="fleft" alt='apróhirdetés' />
		</div>
		<div>
			<img src='./images1/x4a.gif' width="21px" height="13px" class="fleft" alt='apróhirdetés' /> 
			<img src='./images1/x4bg.gif' width="455px" height="13px" class="fleft" alt='apróhirdetés' /> 
			<img src='./images1/x4b.gif' width="21px" height="13px" class="fleft" alt='apróhirdetés' />
		</div>
		<div>
			<img src='./images1/x5bga.gif' width="21px" height="<?php print $panel['height']; ?>px" class="fleft" alt='apróhirdetés' /> 
			<div class="hpbody" style="height:<?php print $panel['height']; ?>px">
				<?php if ($panel['body'] != '') print $panel['body']; else { ?>

				<?php } ?>           			
			</div>
			<img src='./images1/x5bgb.gif' width="21px" height="<?php print $panel['height']; ?>px" class="fleft" alt='apróhirdetés' />
		</div>
		<div>
			<img src='./images1/x6a.gif' width="21px" height="34px" class="fleft" alt='apróhirdetés' /> 
			<img src='./images1/x6bg.gif' width="455px" height="34px" class="fleft" alt='apróhirdetés' /> 		
			<img src='./images1/x6b.gif' width="21px" height="34px" class="fleft" alt='apróhirdetés' />
		</div>
	</div>

	<br />
	<br />

<?php } ?>

<br />

</div>

<?php include ("right.php"); ?>

<?php include ("footer.php"); ?>
